<!DOCTYPE html>
<!-- saved from url=(0056)http://startbootstrap.com/templates/simple-sidebar.html# -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Panel</title>

<?php $this->load->view('panel_head');?>
</head>

<body onload="startTime()">
<div style="background-color:#333; height:46px; width:100%; position:fixed; z-index:10000;">
  <?php $this->load->view('panel_header');?>
</div>
<div style="height:46px;"></div>
<div id="wrapper"> 
  
  <!-- Sidebar -->
  <div id="sidebar-wrapper">
    <?php $this->load->view('panel_sidebar');?>
  </div>
  
  <!-- Page content -->
  <div id="page-content-wrapper">
    <div class="content-header">
      <h1><span class="glyphicon glyphicon-cog"></span> Setting</h1>
    </div>
    <!-- Keep all page content within the page-content inset div! --> 
    
    <?php echo form_open('psetting/setting');?>
    <div class="page-content inset"> 
      <!-- <div class="panel panel-default"> -->
      <div class="panel panel-default">
        <div class="panel-body">
          <div class="row">
            <div class="col-md-6">
              <table>
                <tr>
                  <td width="130">Web Service</td>
                  <td width="20">:</td>
                  <td><input type="text" class="form-control" placeholder="Web Service" name="web_name" value="<?php echo @$service[0]['web_name'];?>" ></td>
                </tr>
                <tr>
                  <td>Website Address</td>
                  <td>:</td>
                  <td><a href=<?php echo base_url();?>><?php echo base_url();?></a></td>
                </tr>
              </table>
              </br>
            </div>
            <!-- <div class="col-md-6"> -->
            <div class="col-md-6">
              <table >
                <tr valign="top">
                  <td width="130">Logo</td>
                  <td width="20">:</td>
                  <td height="60" >
                  	<?php if(@$service[0]['web_logo'] != '') { ?>
                  	<img src="<?php echo base_url();?>img/<?php echo @$service[0]['web_logo'];?>" width="100em"/>
                    <?php } ?>
                  </td>
                </tr>
                <tr>
                  <td></td>
                  <td></td>
                  <td><div style="padding-top:0.7em;">
                     <button class="btn btn-default " data-toggle="modal" data-target="#delete" type="button">Customised Logo</button>
                  
                      
                    </div></td>
                </tr>
              </table>
            </div>
            <!-- <div class="col-md-6"> --> 
          </div>
          <!-- <div class="row"> --> 
          
        </div>
        <!-- <div class="panel-body"> --> 
        
      </div>
      <!-- <div class="panel panel-default"> -->
      

      
      <?php $i=0; ?>
      <?php foreach($setting as $setting) { ?>
      <div class="panel panel-default">
        <div class="panel-body">
          <div class="row">
            <div class="col-md-6">
              <table width="100%">
                <tr>
                  <td rowspan="2" width="70em" style="padding-top:10px"><?php 
				  if($connection[$i] == 'Connected'){
					  print '<font color="#5cb85c" size="+6"><span class="glyphicon glyphicon-hdd"></span></font>';
				  }else{
					  print '<font color="d9534f" size="+6"><span class="glyphicon glyphicon-remove"></span></font>';
				  }
				  ?></td>
                  <td><input type="text" class="form-control" placeholder="Streaming Server" name="server_name_<?php echo $i;?>" value="<?php echo @$setting['server_name'];?>" style="width:15em;" required>
                  <input type="hidden" name="server_id_<?php echo $i;?>" value="<?php echo $setting['server_id'];?>">
                  </td>
                </tr>
                <tr>
                  <td><input type="text" class="form-control" placeholder="IP Address" name="server_ip_<?php echo $i;?>" value="<?php echo @$setting['server_ip']?>" style="width:15em;" required></td>
                </tr>
                <tr>
                	<td colspan="2"> 
                    <?php $this->db->where('server_id' ,$setting['server_id']); 
					$query = $this->db->count_all_results('vdo'); ?>                    
                    <button type="button" class="btn btn-link" data-toggle="modal" data-target="#edit_server_<?php echo $i; ?>"><span class="glyphicon glyphicon-cog"></span> FTP setting</button>
                    <?php if($query == 0) { ?><button type="button" class="btn btn-link" data-toggle="modal" data-target="#remove_server_<?php echo $i; ?>"><span class="glyphicon glyphicon-trash"></span> Remove server</button><?php } ?>
                    </td>
                </tr>
              </table>
            </div>
            <!-- <div class="col-md-6"> -->
            
            <div class="col-md-6">
              <table>
                <tr>
                  <td width="130em">Vdo Files</td>
                  <td width="20em">:</td>
                  <td><?php 					
					$this->db->join('server','server.server_id = vdo.server_id','left');
					$this->db->where('server_ip',$setting['server_ip']);
					echo $this->db->count_all_results('vdo')
				   ?> files</td>
                </tr>
                <tr>
                  <td>File Size</td>
                  <td>:</td>
                  <td>
                  <?php				  	
					$this->db->join('server','server.server_id = vdo.server_id','left');
					$this->db->where('server_ip',$setting['server_ip']); 
					$this->db->select_sum('vdo_size');
					$query = $this->db->get('vdo');
					$size = $query->result_array();					
					$bytes =  $size[0]['vdo_size'];
					
					$CI =& get_instance();
					$CI->load->library('calculate_byte');
					$vdofile_server = $CI->calculate_byte->index($bytes);
					
					printf ('%.2f ', $vdofile_server[0]);
                    echo $vdofile_server[1];
				  ?>
                  </td>
                </tr>
              </table>
            </div>
            <!-- <div class="col-md-6"> --> 
            
          </div>
          <!-- <div class="row"> --> 
        </div>
        <!-- <div class="panel-body"> --> 
        
      </div>

      <?php $i++;}?>
      
      
      
            
      
       <div class="panel panel-default">
        <div class="panel-body" align="center">
     <button type="button" class="btn btn-success" style="height:5em;"  data-toggle="modal" data-target="#new_server"><span class="glyphicon glyphicon-plus-sign"></span>&nbsp;Add New Streaming Server</button>
        </div>
        </div>
      
      
      
      
      <div class="panel panel-default">
        <div class="panel-body">
          <div class="row">
            <div class="col-md-6">
              <table>
                <thead>
                  <tr>
                    <td colspan="3"><h4><strong>Summarization</strong></h4></td>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <td width="130em">Streaming</td>
                    <td width="20em">:</td>
                    <td><?php echo $count ?> servers</td>
                  </tr>
                  <tr>
                    <td>Online</td>
                    <td>:</td>
                    <td><?php echo $connection['online'];?></td>
                  </tr>
                  <tr>
                    <td>Offline</td>
                    <td>:</td>
                    <td><?php echo $connection['offline'];?></td>
                  </tr>
                  <tr>
                    <td>Vdo Files</td>
                    <td>:</td>
                    <td><?php echo $this->db->count_all_results('vdo'); ?> files</td>
                  </tr>
                  <tr>
                    <td>File Size</td>
                    <td>:</td>
                    <td>
					 <?php printf ('%.2f', $sum_vdofile[0]); ?>
                     <?php echo $sum_vdofile[1];?></td>
                  </tr>
                </tbody>
              </table>
            </div>
            <div class="col-md-6"> </div>
          </div>
          <!-- <div class="row"> --> 
        </div>
        <!-- <div class="panel-body"> --> 
        
      </div>
      <!-- <div class="panel panel-default"> -->
      
      
      
      <div align="right">
        <button type="submit" class="btn btn-primary">Save</button>
      </div>
      <?php echo form_close();?> </div>
    <!-- <div class="page-content inset"> --> 
    
  </div>
  <!--  <div id="page-content-wrapper"> --> 
  
</div>
<!-- <div id="wrapper"> --> 

<?php $j=0; ?>
<?php foreach($setting_footer as $setting_footer) { ?>
  <!-- edit server -->

<div class="modal fade" id="edit_server_<?php echo $j; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel"><?php echo $setting_footer['server_name'];?></h4>
      </div>
      <div class="modal-body">
      <?php echo form_open('psetting/edit_stream_server'); ?>
        <table width="100%">
        <tr>
             <td>Streaming Server & IP Address</td>  
             </tr>
          <tr>
            <td><input type="text" class="form-control" placeholder="Streaming Server" name="server_name" value="<?php echo $setting_footer['server_name'];?>" required>
            <input type="hidden" value="<?php echo $setting_footer['server_id'];?>" name="server_id">
            </td>
          </tr>
          <tr>
            <td><input type="text" class="form-control" placeholder="IP Address or Domain Name" name="server_ip" value="<?php echo $setting_footer['server_ip'];?>" required></td>
          </tr>
          <tr>
             <td>FTP account name & password</td>  
             </tr>
            <tr>              	
            <td><input type="text" class="form-control" placeholder="FTP account name" name="ftp_name" value="<?php echo $setting_footer['ftp_name'];?>"></td>
          </tr>
          <tr>
            <td><input type="password" class="form-control" placeholder="FTP password" name="ftp_pass" value="<?php echo base64_decode($setting_footer['ftp_pass']); ?>"></td>
          </tr>
          <tr>
            <td align="right" ><button type="submit" class="btn btn-warning">Save</button>
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button></td>
          <tr>
        </table>
        <?php echo form_close();?>
      </div>
    </div>
  </div>
</div>


<!-- edit server -->

 <!-- remove server -->

<div class="modal fade" id="remove_server_<?php echo $j; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Delete</h4>
      </div>
      <div class="modal-body">
       <?php echo form_open('psetting/remove_server');?>
        <table width="100%">
          <tr>
            <td  height="35em" style="vertical-align:top;">Are you sure you want to delete this?</td>
          </tr>
          <tr>
            <td align="right" ><button type="submit" class="btn btn-danger">Delete</button>
              <button type="button" class="btn btn-default" data-dismiss="modal">Cancle</button>
              <input type="hidden" name="server_id" value="<?php echo $setting_footer['server_id']; ?>"></td>
          <tr>
        </table>
        <?php echo form_close();?>
      </div>
    </div>
  </div>
</div>


<!-- remove server -->

<?php $j++; } ?>

<!-- add new server -->

<div class="modal fade" id="new_server" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Add New Streaming Server</h4>
      </div>
      <div class="modal-body">
      <?php echo form_open('psetting/add_stream_server'); ?>
        <table width="100%">
        <tr>
             <td>Streaming Server & IP Address</td>  
             </tr>
          <tr>
            <td><input type="text" class="form-control" placeholder="Streaming Server" name="server_name" required></td>
          </tr>
          <tr>
            <td><input type="text" class="form-control" placeholder="IP Address or Domain Name" name="server_ip" required></td>
          </tr>
            <tr>
             <td>FTP account name & password</td>  
             </tr>
            <tr>        	
            <td><input type="text" class="form-control" placeholder="FTP account name" name="ftp_name"></td>
          </tr>
          <tr>
            <td><input type="password" class="form-control" placeholder="FTP password" name="ftp_pass"></td>
          </tr>
          <tr>
            <td align="right" ><button type="submit" class="btn btn-warning">Save</button>
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button></td>
          <tr>
        </table>
        <?php echo form_close();?>
      </div>
    </div>
  </div>
</div>


<!-- add new server -->




 <!-- upload -->
 <?php echo form_open_multipart('psetting/customlogo');?>
<div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Select and Upload Your Logo</h4>
      </div>
      <div class="modal-body">
        <table width="100%">
          <tr>
            <td><input type="file" name="userfile" size="20" required/></td>
          </tr>
          <tr>
            <td align="center" ><button type="submit" class="btn btn-primary">Upload</button></td>
          <tr>
        </table>
      </div>
    </div>
  </div>
</div>
<?php echo form_close();?>
<!-- upload --> 

<!-- Custom JavaScript for the Menu Toggle --> 
<script>
    $("#menu-toggle").click(function(e) {
        e.preventDefault();
        $("#wrapper").toggleClass("active");
    });
</script>
</body>
</html>